package com.yanqu.road.server.cmd.banquet.cross.goodbanquet;

import com.yanqu.road.pb.banquet.CrossBanquetProto;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.command.Command;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.manger.player.GamePlayerMgr;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.ClientProtocol;
import com.yanqu.road.server.protocol.Protocol;
import io.netty.channel.ChannelHandlerContext;

import java.util.List;

/**
 * @Description 开启百福宴会 跨服返回
 * @Author cwq
 * @Data 2021/11/9 14:34
 */
@Cmd(code = Protocol.S_GOOD_BANQUET_OPEN_SYN_FROM_CROSS, desc = "开百福宴同步给区服 跨服返回区服 协议")
public class GoodBanquetOpenSynFromCrossCmd implements Command {

    @Override
    public void execute(ChannelHandlerContext ctx, YanQuMessage packet) throws Exception {
        CrossBanquetProto.BroadcastGoodBanquetOpenMsg crossMsg = CrossBanquetProto.BroadcastGoodBanquetOpenMsg.parseFrom(packet.getBytes());
        List<GamePlayer> playerList = GamePlayerMgr.getAllOnlinePlayer();
        for(GamePlayer player : playerList){
            player.sendPacket(ClientProtocol.U_CROSS_GOOD_BANQUET_BROADCAST_CAN_JOIN_TIME, crossMsg.toBuilder());
        }
    }
}
